package com.yonyou.le.unattended.service;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.yonyou.le.unattended.util.HttpRequestUtil;
import com.yonyou.le.unattended.util.ProConstant;

@Component
public class LeUserService {
	@Autowired
	private ProConstant constant;

	public boolean findUserByNamePassword(String userName, String passWord) {
		Map<String, String> argMap = new HashMap<String, String>();
		argMap.put("user", userName);
		argMap.put("password", passWord);
		argMap.put("datasource",constant.datasource );
		String serviceURL="Http://"+constant.ip+":"+constant.port+constant.loginService;
		String ret=HttpRequestUtil.clientPOST(serviceURL, argMap, "gbk");
		if("true".equals(ret)){
			return true;
		}else{
			return false;
		}
	}

//	/**
//	 * 设定安全的密码，生成随机的salt并经过1024次 sha-1 hash
//	 */
//	private void entryptPassword(MgrUser user) {
//		byte[] salt = Digests.generateSalt(SALT_SIZE);
//		user.setSalt(Encodes.encodeHex(salt));
//		byte[] hashPassword = Digests.sha1(user.getPlainPassword().getBytes(),
//				salt, HASH_INTERATIONS);
//		user.setPassword(Encodes.encodeHex(hashPassword));
//	}
//
//	/**
//	 * 创建动态查询条件组合.
//	 */
//	public Specification<MgrUser> buildSpecification(
//			Map<String, Object> searchParams) {
//		Map<String, SearchFilter> filters = SearchFilter.parse(searchParams);
//		Specification<MgrUser> user = DynamicSpecifications.bySearchFilter(
//				filters.values(), MgrUser.class);
//		return user;
//	}

}
